var SelectSupplier = 
'<div class="modal" id="Selectspuler" tabindex="-1" role="dialog" aria-hidden="true">'+
	'<div class="modal-dialog" style="width: 800px !important;">'+
		'<div class="modal-content">'+
			'<div class="modal-header">'+
				'<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>'+
				'<h4 class="modal-title">选择供应商</h4>'+
				'<div class="form-box2">'+
					'<div class="have-ipt-box">'+
						'<label class="ipt-label" for="">名称/代码：</label>'+
						'<input class="ipt-self1" type="text" name="name" id="supname" value="" />'+
					'</div>'+
					'<div class="form-btn-box form-btn-box2">'+
						'<button class="btn-blue" id="supplier-selectBtn">'+
							'<img src="../img/btn-icon/search.png"/>'+
							'<span>查询</span>'+
						'</button>'+
						'<button class="btn-green" id="supplier-closeBtn">'+
							'<img src="../img/btn-icon/close.png"/>'+
							'<span>关闭</span>'+
						'</button>'+
					'</div>'+
					'<table id="tableSelectspuler"></table>'+
				'</div>'+
			'</div>'+
		'</div>'+
	'</div>'+
'</div>';
$('body').append(SelectSupplier);
$("#tableSelectspuler").bootstrapTable({ // 对应table标签的id
	//url: DOMAIN+'/v1/supplier'+isLogin,
	method: 'get',
	cache: false,
	striped: true,
	pagination: true,
	pageSize: 10,
	pageNumber: 1,
	pageList: [10, 20],
	search: false,
	showColumns: false, 
	clickToSelect: true,
	queryParams: queryParams,
	smartDisplay: false,
	columns: [{
		field: "id",
		title: "计划id",
		align: "center",
		valign: "middle",
		sortable: "true",
		visible: false
	}, {
		field: "code",
		title: "系统编码",
		align: "center",
		valign: "middle",
		sortable: "true"
	}, {
		field: "name",
		title: "商户名称",
		align: "center",
		valign: "middle",
		sortable: "true"
	}, {
		field: "fax",
		title: "商户代码",
		align: "center",
		valign: "middle",
		sortable: "true"
	}, {
		field: "address",
		title: "地址",
		align: "center",
		valign: "middle",
		sortable: "true"
	}],	
	onDblClickRow: function (row) {
		Selectspuler(row);
		//模拟关闭弹框
		  $('#Selectspuler').click();
	},
	formatNoMatches: function() {
		return '没有找到匹配的记录';
	}
});
function queryParams(params) {
	return params;
};

//查询
$("#supplier-selectBtn").click(function(){
	//新查询参数
	function queryParamNew(params) {
		var params = {};
		params.code = $("#supcode").val();
		params.name = $("#supname").val();
		return params;
	};
	var url =DOMAIN+'/v1/supplier'+isLogin;
	$('#tableSelectspuler').bootstrapTable(
			'refreshOptions',
			{
				url: url,
				//查询参数
				queryParams: queryParamNew
			}
		);
	
})

//关闭
$("#supplier-closeBtn").click(function(){
	$('#Selectspuler').click();
})

	//打开选择框时查询
	$('#Selectspuler').on('shown.bs.modal', function () {
		$('#tableSelectspuler').bootstrapTable(
			'refreshOptions',
			{
				url: DOMAIN+'/v1/supplier'+isLogin,
			}
		);
	
	})